package com.lx.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * 过滤器入门
 */
@WebFilter("/login")  //所有访问资源之前，都会执行该资源
public class FilterDemo1 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
        //对request请求消息增强
        System.out.println("请求。。。。");
        //放行
        chain.doFilter(req, resp);
        //对response响应消息增强
        System.out.println("响应.....");
    }

    @Override
    public void destroy() {

    }
}
